<template>
  <div class="index-wrapper">
    <portal-header :current-index="currentIndex" />
    <div class="content-wrapper">
      <!-- 轮播图 -->
      <index-banner />
      <!-- 新闻 -->
      <index-news />
    </div>
    <portal-footer />
  </div>
</template>

<script>
import { WOW } from 'wowjs'
import PortalHeader from './components/PortalHeader'
import PortalFooter from './components/PortalFooter'
import IndexBanner from './components/index/Banner.vue'
import IndexNews from './components/index/News.vue'
import portalUtil from '@/utils/portal-util'
import { mapGetters } from 'vuex'
import { formatDates } from '@/utils/formatdate'

export default {
  name: 'PortalIndex',
  components: {
    PortalHeader,
    PortalFooter,
    IndexBanner,
    IndexNews
  },
  filters: {
    formatTime(val) {
      if (val) {
        return formatDates(val, 'yyyy-MM-dd')
      }
    }
  },
  data() {
    return {
      staList: [],
      staData: null,
      currentIndex: 0,
      startVal: portalUtil.startVal,
      numSeparator: portalUtil.numSeparator,
      duration: portalUtil.dataDuration,
      infoCategoryCode: portalUtil.infoCategoryCode
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  created() {
  },
  mounted() {
    this.$nextTick(() => {
      // 在dom渲染完后,再执行动画
      const wow = new WOW({
        live: false
      })
      wow.init()
    })
  },
  methods: {
    getImg(id) {
      return this.baseApi + '/api/portal/viewImage/' + id
    },
    checkUser() {
      if (this.name) {
        this.userFlag = true
      } else {
        this.userFlag = false
      }
    },
    showLogin() {
      if (!this.userFlag) {
        this.$refs.protalHeader.handleLoginDialogShow()
      }
    }
  }
}
</script>

<style lang="scss">
@import '~@/styles/portal/common.scss';
</style>
<!--<style src="@/styles/portal/common.scss" scoped></style>-->
<style lang="scss" scoped>
.index-wrapper {
}
</style>
